"""
购物：
    1.用户的账户里有钱
    2.用户可推一个空的购物车进商场
    3.开始购物，将自己想要的商品添加购物车
    4.打印购物小条
"""
money = 300
shoppingCart = []
goods = {
    "荷花": 35,
    "利群": 25,
    "芙蓉王": 26,
    "云龙": 15,
    "中华": 45
}
while True:
    shop = str(input("请输入你想购买的商品,退出购买请输入q/Q:"))
    if shop in goods:
        if money >= goods[shop]:
            shoppingCart.append(shop)
            money -= goods[shop]
            print("恭喜，购买成功!您的余额为:", money)
        else:
            print("余额不足")
    elif shop == "q" or shop == "Q":
        if len(shoppingCart) == 0:
            print("欢迎下次再来")
            break
        else:
            total = 0
            print("购物小票:")
            for i in range(0, len(shoppingCart)):
                total += goods[shoppingCart[i]]
                print(shoppingCart[i], goods[shoppingCart[i]])
            print("总价:", total, "卡余额:", money)
            break
    else:
        print("暂无此商品")

